<?php
// 调试日志查看器
?>
<!DOCTYPE html>
<html>
<head>
    <title>调试日志</title>
    <meta charset="utf-8">
    <style>
        body { font-family: monospace; background: #f5f5f5; }
        .log-entry { margin: 10px 0; padding: 10px; background: white; border-left: 4px solid #007cff; }
        .error { border-left-color: #ff4444; }
        .success { border-left-color: #00aa44; }
        pre { overflow-x: auto; }
    </style>
</head>
<body>
    <h1>调试日志查看器</h1>
    
    <h2>PHP错误日志位置</h2>
    <p>Error Log: <?php echo ini_get('error_log') ?: '未设置'; ?></p>
    <p>Log Errors: <?php echo ini_get('log_errors') ? '开启' : '关闭'; ?></p>
    
    <h2>实时错误日志</h2>
    <div id="logs">
        <?php
        $errorLog = ini_get('error_log');
        if ($errorLog && file_exists($errorLog)) {
            $lines = file($errorLog);
            $recentLines = array_slice($lines, -20); // 最近20行
            foreach ($recentLines as $line) {
                $class = strpos($line, 'error') !== false ? 'error' : '';
                echo "<div class='log-entry $class'>" . htmlspecialchars($line) . "</div>";
            }
        } else {
            echo "<p>无法找到错误日志文件</p>";
        }
        ?>
    </div>
    
    <h2>测试链接</h2>
    <ul>
        <li><a href="test_db.php" target="_blank">测试数据库连接</a></li>
        <li><a href="check_table.php" target="_blank">检查表结构</a></li>
        <li><a href="api/test_update.php" target="_blank">测试更新API</a></li>
    </ul>
    
    <script>
        // 每5秒刷新日志
        setTimeout(() => location.reload(), 5000);
    </script>
</body>
</html>